---
title: Basic Agent 
---

We have a comprehensive, step-by-step [guide to building agents in LlamaIndex.TS](/typescript/framework/tutorials/agents/1_setup) that we recommend to learn what agents are and how to build them for production. But building a basic agent is simple:

## Set up

In a new folder:

```package-install
npm init
npm i -D typescript @types/node
npm i @llamaindex/openai @llamaindex/workflow llamaindex zod
```

## Run agent

Create the file `example.ts`. This code will:

- Create two tools for use by the agent:
  - A `sumNumbers` tool that adds two numbers
  - A `divideNumbers` tool that divides numbers
- Give an example of the data structure we wish to generate
- Prompt the LLM with instructions and the example, plus a sample transcript

<include cwd>../../examples/agents/agent/openai.ts</include>

To run the code:

```package-install
npx tsx example.ts
```

You should expect output something like:

```
{
  result: '5 + 5 is 10. Then, 10 divided by 2 is 5.',
  state: {
    memory: Memory {
      messages: [Array],
      tokenLimit: 30000,
      shortTermTokenLimitRatio: 0.7,
      memoryBlocks: [],
      memoryCursor: 0,
      adapters: [Object]
    },
    scratchpad: [],
    currentAgentName: 'Agent',
    agents: [ 'Agent' ],
    nextAgentName: null
  }
}
Done
```
